home *** CD-ROM | disk | FTP | other *** search
/ PC Media 4 / PC MEDIA CD04.iso / share / prog / res104 / source / portable.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-30  |  4.0 KB  |  137 lines

  1. #if !defined(PORTABLEdotH)
  2. #define PORTABLEdotH
  3.  
  4.  
  5. /****
  6. ***** Deal with protected and real mode compilers.
  7. ****/
  8.  
  9. #if defined(__TURBOC__)                               /* Borland */
  10.   #define _near                 near
  11.   #define _far                  far
  12.   #define _huge                 huge
  13. #elif defined(__GNUC__)                               /* GNU */
  14.   #define _near
  15.   #define _far
  16.   #define _huge
  17.   #define PROTECTED_MODE_32
  18. #else                                                 /* who knows? */
  19.   #define _near                 near
  20.   #define _far                  far
  21.   #define _huge                 huge
  22. #endif
  23.  
  24.  
  25. /****
  26. ***** Standardize variable type names.
  27. ****/
  28.  
  29. #if defined(__TURBOC__)                               /* Borland */
  30.   typedef long                  bigint;
  31.   typedef unsigned long         biguint;
  32. #elif defined(__GNUC__)                               /* GNU */
  33.   #define bigint                int
  34.   #define biguint               unsigned
  35. #else                                                 /* who knows? */
  36.   #if sizeof(int)==4
  37.     typedef int                 bigint;
  38.     typedef unsigned            biguint;
  39.   #else
  40.     typedef long                bigint;
  41.     typedef unsigned long       biguint;
  42.   #endif
  43. #endif
  44.  
  45.  
  46. /****
  47. ***** Standardize file macros.
  48. ****/
  49.  
  50. #if defined(__TURBOC__)                               /* Borland */
  51.   #include <dir.h>
  52.   #define PATH_MAX              MAXPATH
  53.   #define DRIVE_MAX             MAXDRIVE
  54.   #define DIR_MAX               MAXDIR
  55.   #define FILE_MAX              MAXFILE
  56.   #define EXT_MAX               MAXEXT
  57. #elif defined(__GNUC__)                               /* GNU */
  58.   #include <sys/param.h>
  59.   #define PATH_MAX              MAXPATHLEN
  60.   #define DRIVE_MAX             3
  61.   #define DIR_MAX               66
  62.   #define FILE_MAX              9
  63.   #define EXT_MAX               5
  64. #else                                                 /* who knows? */
  65.   #define PATH_MAX              80
  66.   #define DRIVE_MAX             3
  67.   #define DIR_MAX               66
  68.   #define FILE_MAX              9
  69.   #define EXT_MAX               5
  70. #endif
  71.  
  72.  
  73. /****
  74. ***** Standardize error macros.
  75. ****/
  76.  
  77. #if defined(__TURBOC__)                               /* Borland */
  78.   #define ERROR_ZERO            EZERO
  79.   #define ERROR_NOT_SAME        ENOTSAM
  80. #else                                                 /* who knows? */
  81.   #define ERROR_ZERO            0
  82.   #define ERROR_NOT_SAME        17
  83. #endif
  84.  
  85.  
  86. /****
  87. ***** Standardize string macros.
  88. ****/
  89.  
  90. #if defined(__TURBOC__)                               /* Borland */
  91.   #define STRING_UPPER(s)       strupr(s)
  92.   #define STRING_CMP_I(s1,s2)   stricmp(s1,s2)
  93. #else                                                 /* who knows? */
  94.   char *STRING_UPPER(char *s);
  95.   int STRING_CMP_I(char *s1, char *s2);
  96. #endif
  97.  
  98.  
  99. /****
  100. ***** Standardize the memory management macros.
  101. ****/
  102.  
  103. #if defined(__TURBOC__)                               /* Borland */
  104.   #include <alloc.h>
  105.   #define ALLOC_MEM(b)          farmalloc(b)
  106.   #define FREE_MEM(p)           farfree(p)
  107. #else                                                 /* who knows? */
  108.   #define ALLOC_MEM(b)          malloc(b)
  109.   #define FREE_MEM(p)           free(p)
  110. #endif
  111.  
  112.  
  113. /****
  114. ***** Standardize the file name splitting/merging functions.
  115. ****/
  116.  
  117. #if defined(__TURBOC__)                               /* Borland */
  118.   #define FN_SPLIT(path,drive,dir,name,ext) \
  119.                                 fnsplit(path,drive,dir,name,ext)
  120.   #define FN_MERGE(path,drive,dir,name,ext) \
  121.                                 fnmerge(path,drive,dir,name,ext)
  122. #else                                                 /* who knows? */
  123.   void FN_SPLIT(char *path, char *drive, char *dir, char *fname, char *ext);
  124.   void FN_MERGE(char *path, char *drive, char *dir, char *fname, char *ext);
  125. #endif
  126.  
  127.  
  128. /****
  129. ***** Standardize the memory management functions.
  130. ****/
  131.  
  132. extern void _far *(*resAllocMem)(biguint bytes);
  133.  
  134.                                        
  135.  
  136. #endif
  137.